This repository was archived by the owner on Oct 31, 2024. It is now read-only.
Optimize StringBuilder based loops#50
Closed
slandelle wants to merge 1 commit intoburtcorp:masterfrom
gatling:stringbuilder
Closed
Optimize StringBuilder based loops#50slandelle wants to merge 1 commit intoburtcorp:masterfrom gatling:stringbuilder
slandelle wants to merge 1 commit intoburtcorp:masterfrom
gatling:stringbuilder
Conversation
Motivation: Nodes' internalToString and ParseExceptions uses StringBuilder based loops. Even tough those shouldn't be on the hot path if Expressions are cached, they still can be optimized. Modifications: * Stop using Iterators with nested hasNext tests. Use simple for loops that have a chance of being JIT'ed with escape analysis. * Don't test last element in loop (cf above). Update StringBuilder's length after loop if it wasn't empty. * Don't use StringBuilder#delete that causes a copy of the underlying char array. Update StringBuilder's length instead as we always want to remove the tail. Result: Less allocations
iconara
approved these changes
Jun 7, 2019
Collaborator
iconara
left a comment
There was a problem hiding this comment.
I don't mind the change, and since you've written the code there's no reason not to merge it, but as you say, this is not a hot path…
Please use the Request Review feature in the future, it works better to get my attention than @-ing.
Contributor
Author
|
Shoot, I deleted wrong branch. Will submit again. |
Contributor
Author
Collaborator
Ah, I had no idea. That restriction makes no sense. |
Collaborator
|
I've added you as a "triage" collaborator. |
Contributor
Author
|
Awesome, thanks! |
Collaborator
|
There's also a new snapshot release with all your PRs: https://github.com/burtcorp/jmespath-java/releases/tag/jmespath-0.3.1-SNAPSHOT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
Nodes' internalToString and ParseExceptions uses StringBuilder based loops. Even tough those shouldn't be on the hot path if Expressions are cached, they still can be optimized.
Modifications:
Result:
Less allocations